<? 
define("LOG_TBL", "log"); 
define("HIT_COUNTER_TBL", "hit_counter"); 
define("BLOCK_IP", "0.0.0.0"); 
define("UNIQUE_TIME", "20"); 
define("USER_ONLINE_TIME", "5"); 
define("NO_OF_DIGITS", "5"); 

$u_timestamp = time(); 

if (@getenv("HTTP_X_FORWARDED_FOR")) 
{ $u_ip = @getenv("HTTP_X_FORWARDED_FOR"); } 
else { $u_ip = @getenv("REMOTE_ADDR"); } 

if ($u_ip == BLOCK_IP) 
{ return 1; 
  exit; } 

$u_host = @gethostbyaddr($u_ip); 
$u_referrer = @getenv("HTTP_REFERER"); 


$sql= "SELECT COUNT(*)as row FROM " . LOG_TBL . " WHERE (ip LIKE \"%" . $u_ip . "%\") AND (timestamp + " . (UNIQUE_TIME * 60) . " > " . $u_timestamp . ")"; 
$query = mysql_query($sql) or die("Line 31 Cannot query the database.<br>" . mysql_error()); 
$numrows = mysql_fetch_array($query); 

If ($numrows['row'] <= 0) 
{ 
//get current hit 
//$sql = "SELECT hits FROM " . HIT_COUNTER_TBL . " WHERE (id=1) LIMIT 1"; 
//$query = mysql_query($sql) or die("Line 35 Cannot query the database.<br>" . mysql_error()); 
//$row = mysql_fetch_array($query); 
//$hits = $row["hits"]; 

//$sql = "UPDATE " . HIT_COUNTER_TBL . " SET hits=(hits+1) WHERE id=1" ; 
//mysql_query($sql) or die("Cannot query the database.<br>" . mysql_error()); 

	$sql = "INSERT INTO " . LOG_TBL . " (ip,host,referrer,timestamp) VALUES (\"$u_ip\",\"$u_host\",\"$u_referrer\",\"$u_timestamp\")"; 	
	mysql_query($sql) or die(" Line 52 Cannot query the database.<br>" . mysql_error()); 
} 

//$sql="SELECT COUNT(*) FROM " . LOG_TBL . " WHERE (timestamp + " . (USER_ONLINE_TIME * 60) . " >= " . time() . ")"; 
//$query= mysql_query($sql) or die("Line 68 Cannot query the database.<br>" . mysql_error()); 
//$user_online = @mysql_result($query, 0); 

//$sql = "SELECT hits FROM " . HIT_COUNTER_TBL . " WHERE (id=1) LIMIT 1"; 
//$query = mysql_query($sql) or die("Line 35 Cannot query the database.<br>" . mysql_error()); 
//$row = mysql_fetch_array($query); 
//$hits = $row["hits"]; 

//Zahlen gegen Bilder tauschen

	$gcc_aspect = './/files/';
	$gcc_alt ='counter';
	
 /* $hits = str_replace("0","<img src='$gcc_aspect/0.jpg' $gcc_alt>","$hits");
  $hits = str_replace("1","<img src='$gcc_aspect/1.jpg' $gcc_alt>","$hits");
  $hits = str_replace("2","<img src='$gcc_aspect/2.jpg' $gcc_alt>","$hits");
  $hits = str_replace("3","<img src='$gcc_aspect/3.jpg' $gcc_alt>","$hits");
  $hits = str_replace("4","<img src='$gcc_aspect/4.jpg' $gcc_alt>","$hits");
  $hits = str_replace("5","<img src='$gcc_aspect/5.jpg' $gcc_alt>","$hits");
  $hits = str_replace("6","<img src='$gcc_aspect/6.jpg' $gcc_alt>","$hits");
  $hits = str_replace("7","<img src='$gcc_aspect/7.jpg' $gcc_alt>","$hits");
  $hits = str_replace("8","<img src='$gcc_aspect/8.jpg' $gcc_alt>","$hits");
  $hits = str_replace("9","<img src='$gcc_aspect/9.jpg' $gcc_alt>","$hits");*/

?>